<%@page import="com.liferay.portal.service.AddressLocalServiceUtil"%>
<%@page import="com.liferay.portal.model.Address"%>
<%@page import="com.hellodoctor.util.LConstants"%>
<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="com.hellodoctor.slayer.service.AppointmentLocalServiceUtil"%>
<%@page import="com.hellodoctor.slayer.model.Appointment"%>
<%@include file="/html/common/init.jsp" %>

<h3>Thanks!!</h3>

<%String name= (String)renderRequest.getAttribute("name");
PortletSession portSession = renderRequest.getPortletSession();
String appointmentStr = (String)portletSession.getAttribute("appointmentId");
long appointmentId = Long.valueOf(appointmentStr);
portSession.removeAttribute("appointmentId");
Appointment appointment = AppointmentLocalServiceUtil.fetchAppointment(appointmentId);
Date date = appointment.getAppointmentDate();
DateFormat format = new SimpleDateFormat("EEE, d MMM yyyy");
String [] timeSlots =LConstants.timeSlots;
User doctor = UserLocalServiceUtil.getUser(appointment.getDoctorId());


List<Address> address = doctor.getAddresses();
Address address1 = address.get(0);
%>
<h3> Your Appointment with <font color="red"> Dr.<%= UserLocalServiceUtil.getUser(appointment.getDoctorId()).getFullName() %></font> is scheduled on 
<u> <%= format.format(date) %></u> at <u><%= timeSlots[appointment.getAppointmentTime()] %></u>. </h5>

<h5><u>Address:</u></b></h5>
<h5><%= address1.getStreet1() %></h5>
<h5><%= address1.getCity() %> ,<%= address1.getRegion().getRegionCode()%>-<%= address1.getZip() %></h5>
<h5>Contact:<%= doctor.getPhones().get(0).getNumber() %></h5> 

<aui:button type="submit" value="Close" onClick="closePopup()"></aui:button>

<script type="text/javascript">
function closePopup()
{
	        var dialog = Liferay.Util.getWindow('<portlet:namespace />appointmentPopup');
            dialog.destroy();
}
</script>